﻿@model PhotoBlog.Models.PostM

@if (User != null && User.Identity.IsAuthenticated && User.Identity.Name == "admin")
{
    @Html.ActionLink("Редактировать", "Edit", "Blog", new { id = Model.Post.BlogId }, new { @class = "btn btn-link" })
}

@if (Model != null)
{
    <article class="post-a">
        <header class="post-h"><h1>@Model.Post.HeaderName</h1></header>
        <section class="post-date"><h5>@Model.Post.DatePublish</h5></section>
        <section id="post-c" class="post-c">
            @Html.Raw(Model.Post.ContentText)
        </section>
        <br />
        @{
    Html.RenderPartial("Social");
        }
        <br />
        <div id="vk_like"></div>
        <br />
        <div class="post-paging">
            @if (Model.Paging.HasPrevPage || Model.Paging.HasNextPage)
            {
                if (!Model.Paging.HasPrevPage)
                {
                    <span class="text-muted">Назад</span>@:&nbsp;
                }
                else
                {
                    @Html.ActionLink("Назад", "Posts", new { id = @Model.Paging.PrevPage })
                    @:&nbsp;
                }
                if (!Model.Paging.HasNextPage)
                {
                    <span class="text-muted">Вперед</span>
                }
                else
                {
                    @Html.ActionLink("Вперед", "Posts", new { id = @Model.Paging.NextPage })
                }
            }
        </div>
        <div class="post-comments">
            <div id="vk_comments"></div>
        </div>
    </article>
}
@section scripts
{
    <script type="text/javascript">
        if (VK != undefined) {            
            VK.Widgets.Like('vk_like');            
            VK.Widgets.Comments("vk_comments", { limit: 5, width: "540", attach: "*" });
        }
        $(function () {
            var imgUrl = $("img").first().attr("src");
            $("#image_content").attr('content', imgUrl);
            $("#image_src").attr('href', imgUrl);

            var href = location.href;
            new Ya.share({
                element: 'yashare',
                theme: 'counter',
                elementStyle: {
                    'quickServices': ['vkontakte', 'facebook', 'twitter', 'odnoklassniki', 'gplus']
                },
                link: href,
                image: imgUrl,
                popupStyle: {
                    copyPasteField: true
                }
            });
        });
    </script>
}